import { BasicColumn } from '/@/components/Table';
import { FormSchema } from '/@/components/Table';
import { rules } from '/@/utils/helper/validator';
import { render } from '/@/utils/common/renderUtils';
import { getWeekMonthQuarterYear } from '/@/utils';
//列表数据
export const columns: BasicColumn[] = [
  {
    title: '水果名称',
    align: 'center',
    dataIndex: 'name',
  },
  {
    title: '类别',
    align: 'center',
    dataIndex: 'fruitCategory',
    customRender: ({ text }) => {
      return render.renderDict(text, 'baseinfo_fruit_category');
    },
  },
  {
    title: '规格',
    align: 'center',
    dataIndex: 'spec',
    customRender: ({ text }) => {
      return render.renderDict(text, 'baseinfo_fruit_spec');
    },
  },
  {
    title: '计量单位',
    align: 'center',
    dataIndex: 'unit',
    customRender: ({ text }) => {
      return render.renderDict(text, 'baseinfo_fruit_unit');
    },
  },
  {
    title: '进货单价',
    align: 'center',
    dataIndex: 'purchasePrice',
  },
  {
    title: '销售单价',
    align: 'center',
    dataIndex: 'salePrice',
  },
  {
    title: '存储方式',
    align: 'center',
    dataIndex: 'type',
    customRender: ({ text }) => {
      return render.renderDict(text, 'baseinfo_fruit_storage_type');
    },
  },
  {
    title: '保质期(天)',
    align: 'center',
    dataIndex: 'shelfLife',
  },
  {
    title: '存储温度要求',
    align: 'center',
    dataIndex: 'storageTemp',
  },
  {
    title: '备注',
    align: 'center',
    dataIndex: 'remarks',
  },
];
//查询数据
export const searchFormSchema: FormSchema[] = [
  {
    label: '水果名称',
    field: 'name',
    component: 'JInput',
    colProps: { span: 6 },
  },
  {
    label: '类别',
    field: 'fruitCategory',
    component: 'JDictSelectTag',
    componentProps: {
      dictCode: 'baseinfo_fruit_category',
      placeholder: '请选择类别',
      stringToNumber: true,
    },
    colProps: { span: 6 },
  },
  {
    label: '规格',
    field: 'spec',
    component: 'JDictSelectTag',
    componentProps: {
      dictCode: 'baseinfo_fruit_spec',
      placeholder: '请选择规格',
      stringToNumber: true,
    },
    colProps: { span: 6 },
  },
  {
    label: '进货单价',
    field: 'purchasePrice',
    component: 'JRangeNumber',
    colProps: { span: 6 },
  },
  {
    label: '销售单价',
    field: 'salePrice',
    component: 'JRangeNumber',
    colProps: { span: 6 },
  },
];
//表单数据
export const formSchema: FormSchema[] = [
  {
    label: '水果名称',
    field: 'name',
    component: 'Input',
    dynamicRules: ({ model, schema }) => {
      return [{ required: true, message: '请输入水果名称!' }];
    },
  },
  {
    label: '类别',
    field: 'fruitCategory',
    component: 'JDictSelectTag',
    componentProps: {
      dictCode: 'baseinfo_fruit_category',
      placeholder: '请选择类别',
      stringToNumber: true,
    },
    dynamicRules: () => {
      return [{ required: true, message: '请选择类别!' }];
    },
  },
  {
    label: '规格',
    field: 'spec',
    component: 'JDictSelectTag',
    componentProps: {
      dictCode: 'baseinfo_fruit_spec',
      placeholder: '请选择规格',
      stringToNumber: true,
    },
    dynamicRules: () => {
      return [{ required: true, message: '请选择规格!' }];
    },
  },
  {
    label: '计量单位',
    field: 'unit',
    component: 'JDictSelectTag',
    componentProps: {
      dictCode: 'baseinfo_fruit_unit',
      placeholder: '请选择计量单位',
      stringToNumber: true,
    },
    dynamicRules: () => {
      return [{ required: true, message: '请选择计量单位!' }];
    },
  },
  {
    label: '进货单价',
    field: 'purchasePrice',
    component: 'InputNumber',
    dynamicRules: ({ model, schema }) => {
      return [{ required: true, message: '请输入进货单价!' }];
    },
  },
  {
    label: '销售单价',
    field: 'salePrice',
    component: 'InputNumber',
    dynamicRules: ({ model, schema }) => {
      return [{ required: true, message: '请输入销售单价!' }];
    },
  },
  {
    label: '存储方式',
    field: 'type',
    component: 'JDictSelectTag',
    componentProps: {
      dictCode: 'baseinfo_fruit_storage_type',
      placeholder: '请选择存储方式',
      stringToNumber: true,
    },
    dynamicRules: () => {
      return [{ required: true, message: '请选择存储方式!' }];
    },
  },
  {
    label: '保质期(天)',
    field: 'shelfLife',
    component: 'InputNumber',
  },
  {
    label: '存储温度要求',
    field: 'storageTemp',
    component: 'Input',
  },
  {
    label: '备注',
    field: 'remarks',
    component: 'InputTextArea',
  },
  // TODO 主键隐藏字段，目前写死为ID
  {
    label: '',
    field: 'id',
    component: 'Input',
    show: false,
  },
];

// 高级查询数据
export const superQuerySchema = {
  name: { title: '水果名称', order: 0, view: 'text', type: 'string' },
  fruitCategory: { title: '类别', order: 1, view: 'number', type: 'number', dictCode: 'baseinfo_fruit_category' },
  spec: { title: '规格', order: 2, view: 'number', type: 'number', dictCode: 'baseinfo_fruit_spec' },
  unit: { title: '计量单位', order: 3, view: 'number', type: 'number', dictCode: 'baseinfo_fruit_unit' },
  purchasePrice: { title: '进货单价', order: 4, view: 'number', type: 'number' },
  salePrice: { title: '销售单价', order: 5, view: 'number', type: 'number' },
  type: { title: '存储方式', order: 6, view: 'number', type: 'number', dictCode: 'baseinfo_fruit_storage_type' },
  shelfLife: { title: '保质期(天)', order: 7, view: 'number', type: 'number' },
  storageTemp: { title: '存储温度要求', order: 8, view: 'text', type: 'string' },
  remarks: { title: '备注', order: 9, view: 'textarea', type: 'string' },
};

/**
 * 流程表单调用这个方法获取formSchema
 * @param param
 */
export function getBpmFormSchema(_formData): FormSchema[] {
  // 默认和原始表单保持一致 如果流程中配置了权限数据，这里需要单独处理formSchema
  return formSchema;
}
